/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dsw2.escuela.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.its.dsw2.escuela.modelo.Maestro;

/**
 *
 * @author Maq-8
 */
@Stateless
public class MaestroDao extends AbstractDao<Maestro> implements MaestroDaoLocal {

    @PersistenceContext(unitName = "Escuela-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public MaestroDao() {
        super(Maestro.class);
    }

    @Override
    public boolean findByDuplicity(Maestro teacher) {
        Query q = em.createNamedQuery("Maestro.findByDuplicity");
        q.setParameter("nombre", teacher.getNombre());
        q.setParameter("aMaterno", teacher.getAMaterno());
        q.setParameter("aPaterno", teacher.getAPaterno());
        return !q.getResultList().isEmpty();
    }
}
